import { Injectable } from '@angular/core';
import { SettingsService, TitleService } from '@delon/theme';

/**
 * 用于应用启动时
 * 一般用来获取应用所需要的基础数据等
 */
@Injectable({ providedIn: 'root' })

export class StartupService {
    constructor(
        private settingService: SettingsService,
        private titleService: TitleService
    ) { }

    private viaData(resolve: any, reject: any) {
        const app: any = {
            name: ``,
            description: `一个基于 Antd 中后台前端解决方案，提供更多通用性业务模块，让开发者更加专注于业务。`
        };
        // 应用信息：包括站点名、描述、年份
        this.settingService.setApp(app);
        // 设置页面标题的后缀
        this.titleService.suffix = app.name;
        resolve({});
    }

    load(): Promise<any> {
        return new Promise((resolve, reject) => {
            this.viaData(resolve, reject);
        });
    }
}
